package com.rgp.apidriver.config;

import com.rgp.apidriver.interceptor.TokenInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author nhp
 * @version 1.0
 * @description TODO
 * @date 2024-04-17 21:02
 */
@Configuration
public class WebMvcConfiguration implements WebMvcConfigurer {

    @Bean
    public HandlerInterceptor tokenInterceptor(){
        return new TokenInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tokenInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/verification-code")
                .excludePathPatterns("/check-verification-code")
                .excludePathPatterns("/auth-token")
                .excludePathPatterns("/refresh-token");
    }
}